package com.cn.qgx428.lazydiary.adapter

import android.support.v7.widget.RecyclerView
import android.util.SparseArray
import android.view.View

/**
 * Created by qinguanxiong on 2018/1/14.
 */

class RViewHolder(private val contentView: View) : RecyclerView.ViewHolder(contentView) {

    private val mViews: SparseArray<View>

    init {
        mViews = SparseArray()
    }

    fun <T : View> getView(viewId: Int): T? {
        var view: View? = mViews.get(viewId)
        if (view != null) {
            return view as T?
        } else {
            view = contentView.findViewById(viewId)
            mViews.put(viewId, view)
        }
        return view as T?
    }
}
